// 引入题目集合构造函数
const { Article } = require('../../../model/article')
const pagination =require('mongoose-sex-page')

module.exports = async (req, res) => {
  // 结构获取id参数
  const { id } = req.params;
  // 结构获得查询参数
  const { query, pagenum, pagesize } = req.query;
  // 向数据库中查询数据
  const articles = await pagination(Article).find({ Tauthor: id }).populate('Tauthor').page(pagenum).size(pagesize).exec();
  if(articles) {
    res.send({
      data: articles,
      meta: {
        msg: '查询成功',
        status: 200
      }
    })
  }
}